/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package service;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author andrew
 */
@Entity
@Table(name = "PhotoCollection")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PhotoCollection.findAll", query = "SELECT p FROM PhotoCollection p"),
    @NamedQuery(name = "PhotoCollection.findByIdPhotoCollection", query = "SELECT p FROM PhotoCollection p WHERE p.idPhotoCollection = :idPhotoCollection"),
    @NamedQuery(name = "PhotoCollection.findByDescription", query = "SELECT p FROM PhotoCollection p WHERE p.description = :description"),
    @NamedQuery(name = "PhotoCollection.findByIsHappy", query = "SELECT p FROM PhotoCollection p WHERE p.isHappy = :isHappy")})
public class PhotoCollection implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idPhotoCollection")
    private Integer idPhotoCollection;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "isHappy")
    private boolean isHappy;
    @JoinColumn(name = "Planet_idPlanet", referencedColumnName = "idPlanet")
    @ManyToOne(optional = false)
    private Planet planetidPlanet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "photoCollectionidPhotoCollection")
    private Collection<Photo> photoCollection;

    public PhotoCollection() {
    }

    public PhotoCollection(Integer idPhotoCollection) {
        this.idPhotoCollection = idPhotoCollection;
    }

    public PhotoCollection(Integer idPhotoCollection, String description, boolean isHappy) {
        this.idPhotoCollection = idPhotoCollection;
        this.description = description;
        this.isHappy = isHappy;
    }

    public Integer getIdPhotoCollection() {
        return idPhotoCollection;
    }

    public void setIdPhotoCollection(Integer idPhotoCollection) {
        this.idPhotoCollection = idPhotoCollection;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public boolean getIsHappy() {
        return isHappy;
    }

    public void setIsHappy(boolean isHappy) {
        this.isHappy = isHappy;
    }

    public Planet getPlanetidPlanet() {
        return planetidPlanet;
    }

    public void setPlanetidPlanet(Planet planetidPlanet) {
        this.planetidPlanet = planetidPlanet;
    }

    @XmlTransient
    public Collection<Photo> getPhotoCollection() {
        return photoCollection;
    }

    public void setPhotoCollection(Collection<Photo> photoCollection) {
        this.photoCollection = photoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPhotoCollection != null ? idPhotoCollection.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PhotoCollection)) {
            return false;
        }
        PhotoCollection other = (PhotoCollection) object;
        if ((this.idPhotoCollection == null && other.idPhotoCollection != null) || (this.idPhotoCollection != null && !this.idPhotoCollection.equals(other.idPhotoCollection))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "service.PhotoCollection[ idPhotoCollection=" + idPhotoCollection + " ]";
    }
    
}
